package zj;

import java.util.Scanner;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/31 13:59
 */
public class Solution1 {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int[] money = {1, 5, 10, 50, 100};
        int[] nums = new int[5];
        for(int i = 0; i < 5; i++){
            nums[i] = sc.nextInt();
        }
        int t = sc.nextInt();
        int res = 0;
        int c = 4;
        while(t > 0 && c >= 0){
            if(money[c] > t || nums[c] == 0){
                c--;
                continue;
            }
            t -= money[c];
            nums[c]--;
            res++;
        }
        res = t == 0 ? res : -1;
        System.out.println(res);
    }
}
